package com.xiaoyu.lanling.feature.invite.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.activity.base.BaseDialogFragment
import kotlinx.android.synthetic.main.invite_tip_dialog.*

class InviteTipDialog : BaseDialogFragment() {

    companion object {
        const val KEY_INVIT_TIPS = "key_invite_tips"
        const val TAG = "InviteTipDialog"

        fun create(tips: String): InviteTipDialog {
            val args = Bundle()
            val dialog = InviteTipDialog()
            args.putString(KEY_INVIT_TIPS, tips)
            dialog.arguments = args
            return dialog
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(DialogFragment.STYLE_NO_TITLE, R.style.DialogFullScreenDimStyle)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.invite_tip_dialog, container, false)
    }

    override fun onViewCreatedSafelyAfterAppFinishInit(view: View, savedInstanceState: Bundle?) {
        tip_desc.text = arguments?.getString(KEY_INVIT_TIPS, "") ?: ""
        dialog?.setCancelable(true)
        close.setOnClickListener { dismiss() }
    }
}